package arrayListDemo;

import java.util.ArrayList;

public class Demo3 {
	public static void main(String[] args){
		ArrayList arrayList = new ArrayList();
		arrayList.add(new Car(1, "bmw"));
		arrayList.add(new Car(2, "f1"));
		arrayList.add(new Car(3, "oooo"));
		
//		Car car = (Car)arrayList.remove(0); //delete by 下标，remove会把删除的对象返回
//		Car car2 = new Car(2, "f1");
//		System.out.println(arrayList.remove(car2)); //delete by obj ,return boolean
		
		Car car3 = new Car(6, "benz");
		//System.out.println(car);
		//arrayList.set(2, car3);  //modify
		Car cars = (Car)arrayList.set(2, car3);  //set会把替换的换出来
		System.out.println(cars);
		System.out.println(arrayList.indexOf(car3)); //select
		//查看ArrayList保存对象的数量
		System.out.println(arrayList.size());
		
		System.out.println(arrayList);
	}
}
